<%@ Page Language="C#" MasterPageFile="~/DoctorForum.Master" AutoEventWireup="true" Codebehind="ViewTopic.aspx.cs" Inherits="WebForum.ViewTopic" Title="Doctor Forum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <asp:Panel ID="Panel1" runat="server">
        <table width="100%">
            <tr>
                <td>
                    <div class="forumTitle">
                        <asp:HiddenField ID="HiddenFieldTopicId" runat="server"/>
                        <asp:Label ID="LabelTopicTitle" CssClass="Title" runat="server" Text=""></asp:Label>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelTopicContent" runat="server" Text=""></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Button ID="ButtonReply1" runat="server" Text="Reply" OnClick="ButtonReply_Click" />
                    <asp:Button ID="ButtonEdit1" runat="server" Text="Edit" OnClick="ButtonEdit1_Click" />
                </td>
            </tr>
        </table>
        <%--Topic--%>
        <div class="forumContent">
            <asp:GridView ID="GridView1" DataKeyNames="Id" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1" PageSize="5" AutoGenerateColumns="False" Width="100%">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <table width="100%">
                                <tr>
                                    <td>
                                        <div class="replyTitle">
                                            <asp:HiddenField ID="HiddenFieldSubTopicId" runat="server" Value='<%# DataBinder.Eval(Container.DataItem,"Id") %>'/>
                                            <asp:Label Font-Bold="true" ID="LabelTopicTitle" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Title") %>'></asp:Label>
                                            <b>Poted date: </b>
                                            <asp:Label ID="LabelDesc" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"PostDate") %>'></asp:Label>
                                            <b>Modified date: </b>
                                            <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"ModifiedDate") %>'></asp:Label>
                                            <b>User Post: </b>
                                            <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"User.UserName") %>'></asp:Label>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="replyContent">
                                        <asp:Label ID="Label3" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Content") %>'></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">
                                        <asp:Button ID="ButtonReply2" runat="server" Text="Reply" OnClick="ButtonReply_Click" />
                                        <asp:Button ID="ButtonEdit2" runat="server" Text="Edit" OnClick="ButtonEdit2_Click"/>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
        <%--DataSource for topics--%>
        <asp:ObjectDataSource ID="ObjectDataSource1" TypeName="WebForum.App_Data.TopicDataSource" SelectMethod="ListSubTopics" runat="server">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="0" Name="pID" QueryStringField="id" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server" Visible="false">
        <table width="100%">
            <asp:HiddenField ID="HiddenFieldTopicEditID" runat="server" />
            <tr>
                <td>
                    Reply title
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox Width="60%" ID="TextBoxReplyTitle" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBoxReplyTitle" Display="Dynamic" runat="server" ErrorMessage="Must enter title!"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Reply content
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox Width="100%" ID="TextBoxReplyContent" TextMode="MultiLine" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TextBoxReplyContent" runat="server" ErrorMessage="Must enter content!"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Button ID="ButtonSubmit" runat="server" Text="Submit" OnClick="ButtonSubmit_Click" />     
                    <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="ButtonCancel_Click" />               
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
